<script>
function deletecoupon(id) {
	if(confirm('Are you sure you want to delete this discount code?')) {
		window.location = '<?=base_url()?>admin/system/deletecoupon/' + id;
	}
}
function createcoupon() {
	window.location = '<?=base_url()?>admin/system/coupon/add';
}
</script>
    	<div class="left">
        	<h1>System Settings</h1>
            <div class="bar">

            	<div class="text">Coupons & Discounts</div>
            	<div class="cr"></div>
            </div>
            <div class="box">
            	<h3>Coupon List</h3>
                <div class="row-title">
                	<div class="cat-name">Coupon name // CODE</div>                  
                    <div class="cat-func">Delete</div>
                    <div class="cat-func">Active</div>
                    <div class="cat-func">Edit</div>
                    <div class="cat-func2">Discount</div>
                    <div class="cat-func">Used</div>
                </div>
                <div id="subcat">
                	<?php foreach($coupons as $coupon) { ?>
                    <div class="row-item">
                        <div class="cat-name"><?=$coupon['name']?> // <?=$coupon['code']?></div>
                        <div class="cat-func"><a href="javascript:deletecoupon(<?=$coupon['id']?>)"><img src="<?=base_url()?>img/backend/icon-delete.png" /></a></div>
                        <?php if($coupon['actived'] == 1) { ?>
                        <div class="cat-func"><a href="<?=base_url()?>admin/system/activecoupon/<?=$coupon['id']?>" title="De-active this coupon code"><img src="<?=base_url()?>img/backend/icon-actived.png" /></a></div>
                        <?php } else if($coupon['actived'] == 0) { ?>
                        <div class="cat-func"><a href="<?=base_url()?>admin/system/activecoupon/<?=$coupon['id']?>" title="Active this coupon code"><img src="<?=base_url()?>img/backend/icon-inactived.png" /></a></div>
                        <?php } ?>
                        <div class="cat-func"><a href="<?=base_url()?>admin/system/coupon/edit/<?=$coupon['id']?>"><img src="<?=base_url()?>img/backend/icon-view.png" /></a></div>
                        <div class="cat-func2">
                        	<?php if($coupon['type'] == 1) { print $coupon['value'].'%'; } else { print '$'.$coupon['value']; } ?>
                        </div>
                        <div class="cat-func"><?=$coupon['actual_used_times']?></div>
                    </div>
                    <?php } ?>
                </div>
            </div>
            <div class="box">
            	<input type="button" class="button rounded" value="Create a new coupon" onclick="createcoupon()" />
            </div>
        </div>
        
